package gui;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
/**
 * 
 * @author Daniel Engel
 *
 */
public class ConfirmationDialog extends JDialog {

	private final JPanel contentPanel = new JPanel();
	private Controller controller = new Controller();
	private JButton jaButton, nejButton;

	/**
	 * @author Daniel Engel Launch the application.
	 */
	public static void main(String[] args) {
		try {
			ConfirmationDialog dialog = new ConfirmationDialog();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * Create the dialog.
	 */
	public ConfirmationDialog() {
		setBounds(100, 100, 225, 150);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setLayout(new FlowLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.NORTH);
		{
			JLabel lblOpretbehandling = new JLabel("");
			contentPanel.add(lblOpretbehandling);
		}
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				jaButton = new JButton("Ja");
				jaButton.addActionListener(controller);
				jaButton.setActionCommand("Ja");
				buttonPane.add(jaButton);
				getRootPane().setDefaultButton(jaButton);
			}
			{
				nejButton = new JButton("Nej");
				nejButton.setActionCommand("Nej");
				buttonPane.add(nejButton);
				nejButton.addActionListener(controller);
			}
		}
		{
			JLabel lblNewLabel = new JLabel(
					" Er du sikker på du vil gå videre ?");
			getContentPane().add(lblNewLabel, BorderLayout.CENTER);
		}
	}

	/**
	 * Create the ActionListner
	 */
	class Controller implements ActionListener {
		@Override
		public void actionPerformed(ActionEvent e) {
			if (e.getSource() == jaButton) {
				System.out.println("Hej Hej");
			}
			if (e.getSource() == nejButton) {
				System.out.println("Woop Woop");
			}
		}
	}
}
